﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace EncryptDecrypt
{
    public partial class frmMain : Form
    {

        //CryptorEngine ce = new CryptorEngine();
        public frmMain()
        {
            InitializeComponent();
        }

        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            try
            {
                if (rbDES.Checked)
                tbPassword.Text = CryptorEngine.EncryptString(tbOriginal.Text);

                if (rbMD5_16.Checked)
                    tbPassword.Text = CryptorEngine.GetMd5_16(tbOriginal.Text);

                if (rbMD5_32.Checked)
                    tbPassword.Text = CryptorEngine.GetMd5_32(tbOriginal.Text);
            
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误：" + ex.Message, "加密提示", MessageBoxButtons.OK);
            }
        }

        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            try
            {
                tbOriginal.Text = CryptorEngine.DecryptString(tbPassword.Text);

            }
            catch (Exception ex)
            {
                MessageBox.Show("错误：" + ex.Message, "加密提示", MessageBoxButtons.OK);
            }
        }

        private void rbDES_CheckedChanged(object sender, EventArgs e)
        {
            btnDecrypt.Enabled = rbDES.Checked;
        }
    }
}
